{%- set options = options ?? [] %}
{%- set value = value ?? null %}

{%- set class = (class ?? [])|explodeClass|merge([
    'radio-group',
    (toggle ?? false) ? 'fieldtoggle' : null,
    (disabled ?? false) ? 'disabled' : null,
]|filter) %}

{%- set containerAttributes = {
    class: class,
    data: {
        'target-prefix': targetPrefix ?? false,
    },
}|merge(containerAttributes ?? [], recursive=true) %}

{%- if block('attr') is defined %}
    {%- set containerAttributes = containerAttributes|merge(('<div ' ~ block('attr') ~ '>')|parseAttr, recursive=true) %}
{% endif %}

<fieldset {{ attr(containerAttributes) }}>
    {%- for key, option in options %}
        {%- if option is not iterable %}
            {%- set option = {label: option, value: key} %}
        {%- endif %}
        <div>
            {% include "_includes/forms/radio" with {
                id: loop.first ? (id ?? null) : null,
                name: name ?? null,
                checked: (option.value is defined and option.value == value),
                autofocus: loop.first and (autofocus ?? false) and not craft.app.request.isMobileBrowser(true),
            }|merge(option) only %}
        </div>
    {% endfor %}
</fieldset>
